package io.esirong.eye.lifecycle

import android.app.Activity
import android.app.Application
import io.esirong.eye.Screen

/**
 * Activity Android 生命周期管理
 * <p>初始化后，将负责处理，监控Activity生命周期。你可以通过他获取当前或指定位置的Activity的所处在的生命周期。
 * <P>或是指定特定的生命周期是哪一个Activity
 * Created by 黄嵘才(HuangRc) on 2019/10/8.
 */
class ActivitiesManager {

    companion object {
        /**初始化Activity的管理*/
        @JvmStatic
        fun init(application: Application): Application.ActivityLifecycleCallbacks {
            val callback = ActivityLifecycle(ActivitiesManager())
            application.registerActivityLifecycleCallbacks(callback)
            return callback
        }
    }

    val screen: Screen? = null

    /**当前页面进入*/
    fun setEnter(activity: Activity) {
        screen?.onEnter(activity)
    }

    /**当前页面离开*/
    fun setLeave(activity: Activity) {
        screen?.onLeave(activity)
    }
}